package com.eco.fanliapp.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppOrderDetail;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.entity.AppUserRedReward;
import com.eco.fanliapp.vo.AppUserRedRewardVo;
import com.eco.fanliapp.vo.RedRewardInvitationListVo;

import java.util.List;
import java.util.Map;

/**
 * 红包service
 */
public interface IAppUserRedRewardService extends IService<AppUserRedReward> {

    /**
     * 查询红包类型和红包状态
     * @param status
     * @param type
     * @return
     */
    List<AppUserRedReward> selectStatus(String status, String type);

    /**
     * 根据状态类型查询红包的总和
     * @param status
     * @param type
     * @return
     */
    int selectCountByStatusType(int status, int type);


    /**
     * 创建一条红包记录
     * @param appUserRedReward
     * @return
     */
    int add(AppUserRedReward appUserRedReward);

    /**
     * 修改订单状态
     * @param orderId
     * @param status
     * @return
     */
    int updateAppUserRedReward(Long orderId, int status);


    /**
     * 定时任务查询红包
     * @return
     */
    List<AppUserRedReward> selectAppUserRedReward(Long stime, Long etime);

    /**
     * 查询待领取红包总钱数
     */
    ServerResponse<Map> getTotalMoney(Long userId);


    /**
     *  查询红包类型为2的已领取和未领取的总数
     * @return
     */
    Map invitationMakeMoneyCash(Long userId);

    /**
     * 更新红包状态
     * @return
     */
    ServerResponse updateHbStatus(AppUserRedReward appUserRedReward);

    int updateReceiveHbStatus(AppUserRedReward appUserRedReward);

    /**
     * 通过用户id查询该用户所有的红包以及红包对应的订单订单所对应的用户
     * @param userId
     * @return
     */
    ServerResponse getMoneyListHbType(Long userId);


    /**
     * 定时清理失效的红包
     */
    int updateRedMoneyStatusSx(Long time);


    int updateNewRedMoneyStatusSx(long time);


    void updateHbStatusTask();

    /**
     * 首购红包到支付宝余额
     */
    void updateHbStatusTaskToUser();

    /**
     * 修改红包状态
     *
     * @param appUserRedReward
     * @return
     */
    int updateAppUserRedRewardExpireTime(AppUserRedReward appUserRedReward);

    Integer selectCountMoneyStatus(Long userId, int i);

    AppUserRedReward selectAppUserRedRewardById(Long orderId, Long userId);

    /**
     * 未登录红包弹窗--新
     * @return
     */
    ServerResponse getNotLoginRedMoney();



    /**
     * 下级购买免单是否给予6元奖励
     * @param appUser
     */
    void addInvitationedMoney(AppUser appUser, AppOrderDetail appOrderDetail);

    /**
     * 邀请赚钱文案
     * @param
     */
    ServerResponse invitationDesc();

    /**
     * 榜单
     * @param monthType
     * @return
     */
    List<RedRewardInvitationListVo> findInvitationList(Integer monthType);

    /**
     *
     * @param userId
     * @param type
     * @return
     */
    List<Map> findMoneyListHbType(Long userId, Integer type);

    Map invitationMakeMoneyByUserId(Long userId);

    List<RedRewardInvitationListVo> findInvitationFakeList(Integer type);

    /**
     * 没有发送注册短信的用户红包
     * @return
     */
	List<AppUserRedRewardVo> queryUserRedRewardSm();

    Integer selectStatusByIdAndType(Long userId, int i);

    /**
     * 总裂变人数
     * @param companyId
     * @param flag
     * @return
     */
	Integer totalFissionNumber(Integer companyId, Integer flag);

    /**
     * 新手红包总金额
     * @param companyId
     * @param flag
     * @return
     */
    Double totalRedEnvelopeForBeginners(Integer companyId,Integer type, Integer flag);

    /**
     * 首购红包总额
     * @param companyId
     * @param flag
     * @param flag
     * @return
     */
    String totalFirstPurchaseBonusPacket(Integer companyId, Integer flag);

    /**
     * 签到金币
     * @param companyId
     * @param flag
     * @return
     */
    Double totalSignAmount(Integer companyId, Integer flag);

    /**
     * 新手红包总个数
     * @param companyId
     * @param type
     * @param flag
     * @return
     */
	int totalRedEnvelopeForBeginnersCount(Integer companyId, Integer type, Integer flag);

    /**
     * 推荐佣金
     * @param companyId
     * @param flag
     * @return
     */
	String recommendedCommission(Integer companyId, Integer flag);
}
